//问题反馈
<template>
  <div class="main">
    <p>问题反馈</p>
    <div id="query">
      <label for="">标题: <input type="text" v-model="title" /></label>
      <label for="">创建人: <input type="text" v-model="founder" /></label>
      <label for="">创建日期：
        <el-date-picker v-model="value1" type="date" placeholder="选择日期" value-format="yyyy-MM-dd">
        </el-date-picker>
      </label>
      <div id="btn">
        <button id="first-btn" @click="query">查询</button>
        <button id="added" @click="add">新增问题反馈</button>
        <button id="last-btn" @click="reset">重置</button>
      </div>
    </div>
    <div class="inputDeep">
      <el-table :data="tableData" border style="width: 100%">
        <el-table-column type="index" label="序号"> </el-table-column>
        <el-table-column prop="title" label="标题"> </el-table-column>
        <el-table-column prop="founder" label="创建人"> </el-table-column>
        <el-table-column prop="date" label="创建日期"> </el-table-column>
        <el-table-column label="操作">
          <template slot-scope="scope">
            <el-button @click="edit" type="text" size="small">编辑</el-button>
            <el-button type="text" size="small" @click="delect(scope.row)">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
    </div>

    <div id="page">
      <el-pagination align="right" background layout="prev, pager, next" :total="total" style="margin-top: 30px"
        @current-change="newpage" :current-page="currentPage">
      </el-pagination>
    </div>
  </div>
</template>

<script>
export default {
  components: {},
  data () {
    return {
      pickerOptions: {
        disabledDate () {
          return Date.now();
        },
      },
      total: 0,
      tableData: [],
      value1: "",
      title: "",
      founder: "",
      currentPage: 1,
    };
  },
  computed: {},
  watch: {},
  methods: {
    //查询
    query () {
      this.$axios
        .get("http://192.168.1.154:8080/question/selectQuestion", {
          params: {
            currentPage: this.newpage,
            keyTitle: this.title,
            keyFounder: this.founder,
            keyDate: String(this.value1),
            pageSize: "10",
          },
        })

        .then((data) => {
          console.log(data);
        });
      console.log(typeof String(this.value1));
    },
    //增加
    add () {
      this.$router.push("/questionjump");
      // this.$axios
      //   .post("http://47.100.30.12:8080/question/addQuestion", {})
      //   .then((data) => {
      //     console.log(data);
      //   });
    },
    //编辑
    edit () {
      this.$axios
        .post("http://47.100.30.12:8080/question/updateQuestion", {
          params: {
            id: this.id,
            title: this.title,
            content: "111",
          },
        })
        .then((data) => {
          console.log(data);
        });
    },
    //删除
    delect (num) {
      this.$confirm("是否确认删除该考勤模板 删除后将不可恢复", "删除确认", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          var params = new URLSearchParams();
          params.append("id", num.id);
          console.log(num.id);
          this.$axios
            .post("http://47.100.30.12:8080/question/deleteQuestion", params)
            .then((data) => {
              if (data.data.code == 200) {
                this.question();
                this.$message({
                  type: "success",
                  message: "删除成功!",
                });
              }
            });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除",
          });
        });
    },
    //重置
    reset () {
      this.title = "";
      this.founder = "";
      this.value1 = "";
      this.question();
    },
    //渲染
    question () {
      console.log(this.currentPage);
      this.$axios
        .get("http://47.100.30.12:8080/question/questionIn", {
          params: {
            currentPage: this.currentPage,
            pageSize: 10,
          },
        })
        .then((data) => {
          this.tableData = data.data.data;
          this.total = data.data.total;
          // return(this.total)
        });
    },
    //获取当前页
    newpage (index) {
      this.currentPage = index;
      this.question();
    },
  },
  created () { },
  mounted () {
    this.question();
  },
};
</script>
<style scoped>
.main {
  margin: 0 20px;
  border: 1px solid red;
}
#query {
  margin-top: 20px;
  padding-left: 56px;
}
label {
  margin-right: 48px;
}
input {
  width: 20%;
  height: 30px;
}
#btn {
  margin-top: 30px;
  /* padding-left: 56px; */
}
button {
  height: 30px;
}
#last-btn {
  width: 60px;

  background-color: rgb(70, 167, 247);
  color: white;
  border: 1px rgb(70, 167, 247) solid;
}
#first-btn {
  width: 60px;
  background-color: transparent;
  border: 1px solid black;
  margin-right: 20px;
}
#added {
  margin-top: 20px;
  margin-bottom: 30px;
  width: 100px;
  height: 30px;
  background-color: transparent;
  border: 1px solid black;
  margin-right: 20px;
}
#page {
  margin-top: 20px;
}
.inputDeep >>> .el-table .cell {
  padding: 0 0;
  text-align: center;
}
.inputDeep >>> .el-table .el-table__cell {
  padding: 5px 0;
}
</style>